<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta name="referrer" content="no-referrer" />
    <title>Document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
      }

      .block {
        margin: 20px;
        position: relative;
      }

      .hot-block {
        width: 100%;
        height: 460px;
        display: flex;
        justify-content: start;
        flex-wrap: wrap;
        overflow: hidden;
      }
      .hot-list {
        width: 120px;
        height: 200px;
        margin: 15px;
      }

      .hot-con {
        width: 115px;
        height: 161px;
      }

      .hot-title {
        margin: 5px 0 0;
        overflow: hidden;
        color: #37a;
        font-size: 13px;
        text-align: center;
      }
      
      .hot-title .new {
        width: 16px;
        height: 16px;
        background-color: #63C150;
        color: #fff;
        padding-left: 5px;
        margin-right: 2px;
      }

      img {
        width: 100%;
        height: 100%;
      }
    </style>
  </head>
  <body>
    <div id="app" sy>
      <hotlist :mydata="movie" filmtitle="电影"></hotlist>
      <hotlist :mydata="tv" filmtitle="电视剧"></hotlist>
    </div>
    <script src="./vue.js"></script>
    <script src="./axios.min.js"></script>
    <script type="template" id="con">
      <div class="block">
        <h3>最近热门{{ filmtitle }}</h3>
        <div class="hot-block">
          <div v-for="(item, index) in mydata" class="hot-list" >
            <div class="hot-con">
                <img :src="item.cover" alt="">
                <p class="hot-title">
                  <span class="new" v-if="item.is_new=== true">新
                  </span>
                  <span v-else></span>
                  <span>{{ item.title }}</span>
                  <span v-if="item.rate!=''" style="color:#e09015">{{ item.rate }}</span>
                  <span v-else style="color:#aaa;font-size:12px">暂无评分</span>
                </p>
            </div>
          </div>
        </div>
      </div>
    </script>
    <script>
      let hotlist = {
        props: ["mydata", "filmtitle"],
        template: `#con`,
      };

      let app = new Vue({
        el: "#app",
        data: {
          movie: [],
          tv: [],
        },
        components: {
          hotlist,
        },
        mounted() {
          axios.get("./json/movie.json").then((res) => {
            this.movie = res.data.subjects;
          });
          axios.get("./json/tv.json").then((res) => {
            this.tv = res.data.subjects;
          });
        },
      });
    </script>
  </body>
</html>
